﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Views_order_payment : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if(!IsPostBack){
        loadCustomer();
        //}
        
    }
    
    public void loadCustomer()
    {
        CustomerBus cusBus = new CustomerBus();
        if (Session["username"] == null)
        {
            Response.Redirect("~/order.aspx?step=1");
        }
        else
        {
            string email = Convert.ToString(Session["username"]);
            Customer cus = cusBus.getCustomerByEmail(email);
            txtFirstName.Text = cus.First_name;
            txtLastName.Text = cus.Last_name;
            txtAddress.Text = cus.Address;
            txtCity.Text = cus.City;
            txtPhone.Text = cus.Phone;
        }

    }

    protected void click_Next(object sender, EventArgs e)
    {
        if(radioPayment.SelectedItem.Value.Equals("1")){

            Response.Redirect("~/order.aspx?step=2&payment=1");
            Response.Redirect("~//order.aspx?step=2&payment=1");
        }else if (radioPayment.SelectedItem.Value.Equals("2")){
            Response.Redirect("~//order.aspx?step=2&payment=2");
        }else{
            Response.Redirect("");
        }
        
    }


    protected void click_Cancel(object sender, EventArgs e)
    {
        Response.Redirect("~/order.aspx?step=1");
    }
}